/**
 * Name: Duck
 * @author Zhongtian Jiang
 * @version 1.0
 * 
 * This is a class represents a single duck
 */
import java.awt.Image;
import java.awt.Graphics;


/**
 * @author Master
 * @version $Revision: 1.0 $
 */
public class Duck {
	/**
	 * Field FIFTY.
	 * (value is 50)
	 */
	private static final int FIFTY = 50;

	/**
	 * Field AHUNDRED.
	 * (value is 100)
	 */
	private static final int AHUNDRED = 100;

	/**
	 * Method toString.
	
	 * @return String */
	@Override
	public String toString() {
		return "Duck [duckImage=" + duckImage + ", x=" + x + ", y=" + y + "]";
	}
	
	/**
	 * Field duckImage.
	 */
	public Image duckImage;
	
	/**
	 * Field y.
	 */
	/**
	 * Field x.
	 */
	private int x, y;
	
	/**
     * constructor

     * @param x int
	 * @param y int
	 * @param duckImage Image
	 */
	public Duck(int x, int y, Image duckImage){
		this.x=x;
		this.y=y;
		this.duckImage=duckImage;
	}
	
	/**
     * return the value of X-coordinate

     * @return integer */
	public int getX(){
		return x;
	}
	
	/**
     * return the value of Y-coordinate

     * @return integer */
	public int getY(){
		return y;
	}
	
	/**
     * set the value of X-coordinate

     * @param x int
	 */
	public void setX(int x){
		this.x=x;
	}
	
	/**
     * set the value of Y-coordinate

     * @param y int
	 */
	public void setY(int y){
		this.y=y;
	}
	
	/**
     * check if the X and Y coordinate hit the current duck

     * @param x int
	 * @param y int
	 * @return boolean */
	public boolean canHit(int x, int y){
		return (x >= this.x) && (y >= this.y) && 
				((x - this.x) + (y - this.y) <= AHUNDRED);
	}
	
	/**
     * draw the duck
     * @param g Graphics
	 */
	public void draw(Graphics g){
		g.drawImage(duckImage, x, y, FIFTY, FIFTY, null);
	}
	
}
